// /// 点击背景是否关闭.
// bool dismissOnTap;

// /// 指示器自定义组件
// Widget indicatorWidget;

// /// 展示成功状态的自定义组件
// Widget successWidget;

// /// 展示失败状态的自定义组件
// Widget errorWidget;

// /// 展示信息状态的自定义组件
// Widget infoWidget;

import 'package:flutter/material.dart';
import 'package:surfaceim/common/values/values.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';

class Loading {
  Loading() {
    EasyLoading.instance
          ..displayDuration = const Duration(milliseconds: 2000)
          // ..indicatorType = EasyLoadingIndicatorType.ripple
          ..loadingStyle = EasyLoadingStyle.light
          ..backgroundColor = Colors.white.withOpacity(0)
          // ..progressColor = Colors.red
          ..indicatorSize = 40.0 // 指示器大小
          ..lineWidth = 2
          ..radius = 10.0
          ..indicatorColor = Colors.white
          ..textColor = AppColors.primaryElement
          ..userInteractions = false // loading时的点击穿透
          ..dismissOnTap = false
          ..maskType = EasyLoadingMaskType.custom
          ..maskColor = Colors.white.withOpacity(0.6)
          ..indicatorWidget = SpinKitPumpingHeart(
              color: AppColors.primaryElement) // 自定义 loading Icon
        ;
  }

  static void show([String? text]) {
    EasyLoading.instance.userInteractions = false;
    EasyLoading.show(status: text ?? 'Loading...');
  }

  static void toast(String text) {
    EasyLoading.showToast(text);
  }

  static void dismiss() {
    EasyLoading.instance.userInteractions = true;
    EasyLoading.dismiss();
  }

  // static void showError(String text) {
  //   EasyLoading.showError('Loading...');
  // }
}
